/**
 * Created by wenwu on 02/05/2017.
 */
define(function (require) {
	var Vue = require('vue'),
		Config = require('config'),
		_ = require('ajax'),
		utilities = require('utilities');

    var id = utilities.getParameterByName('id');
	var app = new Vue({
		el: '#enroll_login',
		data: {
			smsSeconds: 60,
			smsAvailable: true,
			formObj: {
                nickname: '',
                phone: ''
			}
		},
		methods: {
			init: function () {
			},
			submit: function () {
                if (app.formObj.nickname.trim() === '') {
                    alert('请输入姓名！');
                } else if (app.formObj.phone.trim() === '') {
                    alert('请输入手机号！');
                } else {
                    var req = {};
                    for (var key in app.formObj) {
						req['enroll.' + key] = app.formObj[key];
                    }
                    req['enroll.blind.id'] = id;
					_(Config.SERVICE.ACTIVITY.ENROLLLOGIN, req, function (data) {
						if (data.type === 'SUCCESS') {
							alert('登录成功！');
                            sessionStorage.setItem('qtid', data.obj.id);
                            location.href = 'enroll_activity.html?typeId='+id;
						} else {
							alert(data.errmsg);
						}
					});
				}
			}
		}
	});
	app.init();
});